/*
 
 * 微信sdk配置
 * 参数
 * 
 * */
/*wx.config({
    debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
    appId: '', // 必填，公众号的唯一标识
    timestamp: '', // 必填，生成签名的时间戳
    nonceStr: '', // 必填，生成签名的随机串
    signature: '',// 必填，签名，见附录1
    jsApiList: [] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
});*/



/*
 
 * 点击日期切换tab内容
 * */
(function(){
	var $nav_items = $('#slider_tab .am-tabs-nav li');
	var $tabsBox = $('#slider_tab .am-tabs-bd');
	var boxW = $('#slider_tab .am-tabs-bd').width();
	var currentIndex = 0;
	
	$nav_items.click(function(){
		currentIndex = $nav_items.index($(this));
		$('#slider_tab .am-tabs-nav li.am-active').removeClass('am-active');
		$(this).addClass('am-active');
		$tabsBox.children('.am-active').removeClass('am-active');
		$tabsBox.children().eq(currentIndex).addClass('am-active')
	});
})();


/*赛选城市*/
$('.filter_tab .filter_tab_area').click(function(){
	$('#filter_modal_area').toggle();
});
$('#filter_modal_area').click(function(){
	$(this).toggle();
});


/*赛选店铺*/
$('.filter_tab .filter_tab_shop').click(function(){
	$('#filter_modal_shop').toggle();
});
$('#filter_modal_shop').click(function(){
	$(this).toggle();
});


/*提示文字*/
function offTip(){
	var $p = $('<p>课程已结束，请下次赶早</p>');
	var $top_tip = $('.top_tip');
	
	$top_tip.append($p);
	setTimeout(function(){
		$p.remove();
	},500)
};




var request = function(url, t, d, res, successcallback, errorcallback, faildcallback) {
	
	successcallback(res);

	
	/*$.ajax(url, {
		type: t,
		data: d,
		dataType: 'json',
		timeout: 5000,
		//headers:{'Content-Type':'application/json'},
		//processData:
		//crossDomain:
		//async:
		success: function(resdata, txtstatus, xhr) {

			if(resdata.head._statuscode == 0) {
				successcallback(resdata.body);
			} else {
				errorcallback(resdata.head._statuscode, resdata.head._statusmsg);
			}

		},
		error: function(xhr, errtype, errthrow) {

			faildcallback(xhr, errtype, errthrow);
		}
	});*/
}


/*获得时间*/
function current(placeholder){
	var d=new Date();
	var m = d.getMonth()+1;
	var datetime = d.getDate();
	
	var isLY = isLeapYear(d.getFullYear());
	var isBM = FisBM(m);
	var isSM = FisSM(m);
	var isSecondM= FisSecondM(m);
	
	var timeList = [];
	var weekday = [];
	var o = [];
	
	
	function isLeapYear(year) {
		return (year % 4 == 0) && (year % 100 != 0 || year % 400 == 0);
	};
	function FisBM(m){
		return [1,3,5,7,8,10,12].indexOf(m)!=-1
	};
	function FisSM(m){
		return [4,6,9,11].indexOf(m)!=-1
	};
	function FisSecondM(m){
		return m==2
	}
	
	
	timeList.push(m+placeholder+datetime);
	
	for(var i=0;i<6;i++){
		
		datetime++;
		
		
		if(isBM&&datetime>31){
			
			
			m++;
			datetime=1;
			
		}else if(isSM&&datetime>30){
			
			m++;
			datetime=1;
			
			
		}else if(isSecondM&&isLY&&datetime>29){
			
			m++;
			datetime=1;
			
		}else if(isSecondM&&!isLY&&datetime>28){
			
			m++;
			datetime=1;
			
		}
		
		
		if(m>12){ m=1;datetime=1}
		isBM = FisBM(m);
		isSM = FisSM(m);
		isSecondM= FisSecondM(m);
		
		timeList.push(m+placeholder+datetime);
		
	}
	
	
	
	switch (d.getDay()){
		case 1:
			weekday = ["今天", '明天', '三', '四', '五', '六', '日']
			break;
		case 2:
			weekday = ["今天", '明天', '四', '五', '六', '日', '一']
			break;
		case 3:
			weekday = ["今天", '明天', '五', '六', '日', "一", '二']
			break;
		case 4:
			weekday = ["今天", '明天', '六', '日', "一", '二', '三']
			break;
		case 5:
			weekday = ["今天", '明天', '日', "一", '二', '三', '四']
			break;
		case 6:
			weekday = ["今天", '明天', "一", '二', '三', '四', '五']
			break;
		case 7:
			weekday = ["今天", '明天', '二', '三', '四', '五', '六']
			break;
	}
	
	
	$.each(timeList, function(index,item) {
		var op = {};
		op.d = item;
		op.w = weekday[index];
		 o.push(op);
	});
	
	
	return o;
};